Attempt to fix the run_with_library_paths test for Windows.
authorPeter Williams <peter@newton.cx>
Tue, 7 Feb 2017 20:55:36 +0000 (15:55 -0500)
committerPeter Williams <peter@newton.cx>
Tue, 7 Feb 2017 20:57:06 +0000 (15:57 -0500)
I was just pasting the build directories into Rust string literals, so Windows
paths with backslashes were being interpreted as having unknown string
escapes. Raw string guards should fix this for all but the most pathological
of build directories.

tests/run.rs

index 8caa3c7e7e0581a11fc02e24fcf764a87562a86b..36d2b5a28aced89d7de0abaf819d31e8d2403da1 100644 (file)
@@ -602,7 +602,7 @@ fn run_with_library_paths() {
     // Only link search directories within the target output directory are
     // propagated through to dylib_path_envvar() (see #3366).
     let mut dir1 = p.target_debug_dir();
-    dir1.push("foo");
+    dir1.push("foo\\backslash");
 
     let mut dir2 = p.target_debug_dir();
     dir2.push("dir=containing=equal=signs");
@@ -614,20 +614,20 @@ fn run_with_library_paths() {
             authors = []
             build = "build.rs"
         "#)
-        .file("build.rs", &format!(r#"
+        .file("build.rs", &format!(r##"
             fn main() {{
-                println!("cargo:rustc-link-search=native={}");
-                println!("cargo:rustc-link-search={}");
+                println!(r#"cargo:rustc-link-search=native={}"#);
+                println!(r#"cargo:rustc-link-search={}"#);
             }}
-        "#, dir1.display(), dir2.display()))
-        .file("src/main.rs", &format!(r#"
+        "##, dir1.display(), dir2.display()))
+        .file("src/main.rs", &format!(r##"
             fn main() {{
                 let search_path = std::env::var_os("{}").unwrap();
                 let paths = std::env::split_paths(&search_path).collect::<Vec<_>>();
-                assert!(paths.contains(&"{}".into()));
-                assert!(paths.contains(&"{}".into()));
+                assert!(paths.contains(&r#"{}"#.into()));
+                assert!(paths.contains(&r#"{}"#.into()));
             }}
-        "#, dylib_path_envvar(), dir1.display(), dir2.display()));
+        "##, dylib_path_envvar(), dir1.display(), dir2.display()));
 
     assert_that(p.cargo_process("run"), execs().with_status(0));
 }